package com.base.core.framework.mybatis.configure;

import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.gitee.magic.jdbc.spring.context.PersistenceEntityRegistryPostProcessor;

/**
 * 文档:https://baomidou.com/introduce
 * DB字段名默认使用驼峰形式
 * mybatis-plus.configuration.map-underscore-to-camel-case=true
 * @author mac
 *
 */
@Configuration
@EnableTransactionManagement
public class MyBatisConfigureation {
	
	@Bean
	public DataSourceTransactionManager dataSourceTransactionManager(DataSource dataSource) {
		return new DataSourceTransactionManager(dataSource);
	}
	
	/**
	 * 持久层实体管理类
	 * @return
	 */
	@Bean
	public static PersistenceEntityRegistryPostProcessor persistenceEntityRegistryPostProcessor() {
		return new PersistenceEntityRegistryPostProcessor();
	}
	
}
